﻿@{
    ViewBag.Title = "Unit";
    Layout = "~/Views/Shared/_Admin.cshtml";
}
<div class="main-content" style="margin-left: 190px; min-height: 575px;">
    <div class="breadcrumbs" id="breadcrumbs">
        <ul class="breadcrumb">
            <li><i class="icon-home home-icon"></i><a href="/admin/index">Dashboard</a> </li>
            <li><a href="javascript:;">楼栋管理</a></li>
            <li class="active">销售单元</li>
        </ul>
        <!-- .breadcrumb -->
    </div>
    <div class="page-content">
        <p>
            <a href="/admin/addunit" class="btn btn-primary">添加销售单元</a>
            <a href="/admin/adddormitory" class="btn btn-success">添加楼栋</a>
        </p>
        <div class="row-fluid">
            <div class="span7">
                <h3 class="row-fluid header smaller lighter purple">
                    <span class="span12">已设定销售单元</span>
                    <!-- /span -->
                </h3>
                <div class="span12">
                    <ol class="dd-list">
                        @{
                        List<CollegeShop.Infrastructure.Entities.Entity.Salesunit> units = ViewBag.Unit;
                        if(units != null && units.Any())
                        {
                            foreach(var item in units)
                            {
                            <li class="dd-item dd2-item">
                                <div class="dd-handle dd2-handle">
                                    <i class="normal-icon icon-group orange bigger-130"></i><i class="drag-icon icon-move bigger-125">
                                    </i>
                                </div>
                                <div class="dd2-content" style="margin-bottom:0px;">
                                    @item.SalesUnitName
                                    <div class="pull-right action-buttons">
                                        <a class="red" href="javascript:;" onclick="confirmunits(@item.ID,'@item.SalesUnitName',this)" title="编辑"> 
                                            <i class="icon-cog bigger-130"></i> 
                                        </a> 
                                    </div>
                                </div>
                                @{
                                    @:<ol class="dd-list">
                                    if(item.Dormitories!=null && item.Dormitories.Any()) 
                                    { 
                                        foreach(var ditem in item.Dormitories) { 
                                            <li class="dd-item dd2-item"> 
                                                <div class="dd-handle dd2-handle"> 
                                                    <i class="normal-icon icon-user red bigger-130"></i>
                                                    <i class="drag-icon icon-move bigger-125"> </i> 
                                                </div> 
                                                <div class="dd2-content"> @ditem.DormitoryName</div> 
                                            </li> 
                                        } 
                                   } 
                                   @:</ol>                
                                } 
                            </li>
                            }
                            }
                        }
                    </ol>
                </div>
            </div>
            <div class="span5">
                <h3 class="row-fluid header smaller lighter purple">
                    <span class="span12">未编排楼栋</span>
                </h3>
                <div class="span12">
                    <ol class="dd-list">
                        @{
                    List<CollegeShop.Infrastructure.Entities.Entity.Dormitory> freeDormitory = ViewBag.Dormitory;
                    if (freeDormitory != null && freeDormitory.Any())
                    {
                        foreach (var item in freeDormitory)
                        {
                            <li class="dd-item dd2-item">
                                <div class="dd-handle dd2-handle">
                                    <i class="normal-icon icon-building blue bigger-130"></i><i class="drag-icon icon-move bigger-125">
                                    </i>
                                </div>
                                <div class="dd2-content">
                                    @item.DormitoryName</div>
                            </li>
                        }
                    }
                    else
                    {
                            <li class="dd-item dd2-item">
                                <div class="dd-handle dd2-handle">
                                    <i class="normal-icon icon-building blue bigger-130"></i><i class="drag-icon icon-move bigger-125">
                                    </i>
                                </div>
                                <div class="dd2-content">
                                    已经全部设置到销售单元</div>
                            </li>
                    }
                        }
                    </ol>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
            ×</button>
        <h3 id="myModalLabel">
            Modal header</h3>
    </div>
    <div class="modal-body">
        <div><i class="icon-spinner icon-spin icon-2x"></i></div>
        <div class="hide" id="infobox">
        <div class="row-fluid" style="line-height:42px;">
            <div class="span3">
                销售单元名称：
            </div>
            <div class="span9">
                <input type="text" class="input-xlarge" />
            </div>
        </div>
        <div class="row-fluid" style="line-height:42px;">
            <div class="span3">
                负责人：
            </div>
            <div class="span9">
                <input type="text" class="input-xlarge" />
            </div>
        </div>
        <div class="row-fluid" style="line-height:42px;">
            <div class="span3">
                联系电话：
            </div>
            <div class="span9">
                <input type="text" class="input-xlarge" />
            </div>
        </div>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">
            关闭</button>
        <button class="btn btn-primary">
            保存</button>
    </div>
</div>
@section tail{
    <script type="text/javascript">
        $(function () {
            $('#domitoryBlock').trigger('click');
        });
        function confirmunits(id, name, sender) {
            $('#myModalLabel').text(name);
            $('#myModal').modal({});
            $.ajax({
                url: '/admin/getunitinfo',
                data: { id: id },
                type:'get',
                dataType: 'json',
                success: function (data) { 
                
                }
            });
        }
    </script>
}
